home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / libs / newlooklib.lha / newlook / createstrgadget.c < prev    next >
C/C++ Source or Header  |  1993-10-03  |  2KB  |  56 lines

  1. /*
  2.  *  CREATESTRGADGET.C
  3.  */
  4.  
  5. #include "newlook.h"
  6.  
  7. struct Gadget *CreateStrGadget(x,y,w, n, id)
  8. SHORT x,y,w,n;
  9. USHORT id;
  10. {
  11.   struct Gadget *g;
  12.   struct StringInfo *si;
  13.  
  14.   ULONG UserHandle= SetNewLookHandle(PRIVATE_HANDLE);
  15.  
  16.   if(g= (struct Gadget *)SmartAllocate(GADGETSIZE))
  17.   {
  18.     if(si= (struct StringInfo *)SmartAllocate(STRINGINFOSIZE))
  19.     {
  20.       if(si->Buffer= (UBYTE *)SmartAllocate(n*sizeof(UBYTE)))
  21.       {
  22.         if(si->UndoBuffer= (UBYTE *)SmartAllocate(n*sizeof(UBYTE)))
  23.         { si->BufferPos    = 0;
  24.           si->MaxChars     = n;
  25.           si->DispPos      = 0;
  26.  
  27.           g->NextGadget    = (struct Gadget *)NULL;
  28.           g->LeftEdge      = x;
  29.           g->TopEdge       = y;
  30.           g->Width         = w;
  31.           g->Height        = 8; /* looks best w/ topaz8 */
  32.           g->Flags         = GADGHCOMP;
  33.           g->Activation    = GADGIMMEDIATE|RELVERIFY;
  34.           g->GadgetType    = STRGADGET;
  35.           g->GadgetRender  = (APTR)NULL;
  36.           g->SelectRender  = (APTR)NULL;
  37.           g->GadgetText    = (struct IntuiText *)NULL;
  38.           g->MutualExclude = (LONG)0L;
  39.           g->SpecialInfo   = si;
  40.           g->GadgetID      = id;
  41.           g->UserData      = (APTR)NULL;
  42.  
  43.           if(AddGBorder(g,NULL))
  44.           {
  45.             MakePrivateHandlePublic(UserHandle);
  46.             return g;   /* --- control flow ends here --- */
  47.           }
  48.         }
  49.       }
  50.     }
  51.   }
  52.   SmartFreeAll(PRIVATE_HANDLE);
  53.   (void)SetNewLookHandle(UserHandle);
  54.   return (struct Gadget *)NULL;
  55. }
  56.